package com.hyj.shop.project.message.controller;

import com.hyj.shop.project.message.domain.Message;
import com.hyj.shop.project.message.service.MessageService;
import com.hyj.shop.project.utils.controller.BaseController;
import com.hyj.shop.project.utils.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.hyj.shop.project.utils.page.TableDataInfo;

import java.util.List;
import java.util.Map;


@Controller
@RequestMapping( "/api")
public class MessageController extends BaseController {
    @Autowired
    private MessageService messageService;

    @RequestMapping(value = "/message/{userId}")
    @ResponseBody
    //查询消息数量
    public AjaxResult queryMessageCount(@PathVariable int userId) {
        System.out.println();
        return messageService.queryMessageCount(userId);
    }
    @RequestMapping(value = "/message/list")
    @ResponseBody
    //查询消息数量
    public TableDataInfo queryMessageList(@RequestParam Map map) {
        startPage();
        List<Message> list = messageService.queryMessageList(map);
        return getDataTable(list);
    }
    @PostMapping(value = "/message/read")
    @ResponseBody
    //查询消息数量
    public AjaxResult messageRead(@RequestBody Map map) {

        System.out.println(map);
        return messageService.messageRead(map);
    }
}
